package com.andremion.floatingnavigationview.sample;

import com.andremion.floatingnavigationview.CircularRevealNavigationView;
import com.andremion.floatingnavigationview.Utils;

import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;

import ohos.agp.utils.RectFloat;
import ohos.app.Context;

import org.junit.Assert;
import org.junit.Test;

/**
 * MainAbilityTest
 *
 * @author hw
 * @since 2021/7/7
 */
public class MainAbilityTest {
    Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();

    /**
     * 测试代入参数为0.
     */
    @Test
    public void testRefreshRegionNone() {
        /* 计算最大半径 */
        int mDownX = 0;
        int mDownY = 0;
        int getLeft = 0;
        RectFloat rectFloat = new RectFloat(0, 0, 0, 0);
        CircularRevealNavigationView circularRevealNavigationView = new CircularRevealNavigationView(context);
        float mMaxRadius = circularRevealNavigationView.getMaxRadius(mDownX, mDownY, rectFloat, getLeft);
        Assert.assertEquals(mMaxRadius, 0.0, 0.0);
    }

    /**
     * 测试代入参数为正常值.
     */
    @Test
    public void testRefreshRegionCore() {
        /* 计算最大半径 */
        int mDownX = 100;
        int mDownY = 100;
        int getLeft = 80;
        RectFloat rectFloat = new RectFloat(0, 0, 150, 200);
        CircularRevealNavigationView circularRevealNavigationView = new CircularRevealNavigationView(context);
        float mMaxRadius = circularRevealNavigationView.getMaxRadius(mDownX, mDownY, rectFloat, getLeft);
        Assert.assertEquals(mMaxRadius, 141.0, 0.0);
    }

    /**
     * 传入正常值.
     */
    @Test
    public void testGetMax() {
        int max = Utils.getMax(new int[]{1, 2, 3, 4});
        Assert.assertEquals(max, 4);
    }
}